package timing.ukulele.project.api;

import timing.ukulele.project.service.BusinessService;
import timing.ukulele.common.ResponseResult;
import timing.ukulele.project.persistent.Business;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/business")
public class BusinessApi {

    private final BusinessService businessService;

    public BusinessApi(BusinessService businessService) {
        this.businessService = businessService;
    }

    @GetMapping("/checkItem")
    @ApiOperation("查询事项是否存在办件")
    public ResponseResult<Long> checkItemProjectExist(@RequestParam("itemId") Long itemId) {
        long count = businessService.lambdaQuery().eq(Business::getItemId, itemId).count();
        return ResponseResult.success(count);
    }
}
